package com.rytx.web.controller.ysp;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.rytx.common.annotation.Log;
import com.rytx.common.core.controller.BaseController;
import com.rytx.common.core.domain.AjaxResult;
import com.rytx.common.enums.BusinessType;
import com.rytx.system.domain.ArtAfterLog;
import com.rytx.system.service.IArtAfterLogService;
import com.rytx.common.utils.poi.ExcelUtil;
import com.rytx.common.core.page.TableDataInfo;

/**
 * 售后操作记录Controller
 * 
 * @author rytx
 * @date 2024-08-29
 */
@RestController
@RequestMapping("/system/afterLog")
public class ArtAfterLogController extends BaseController
{
    @Autowired
    private IArtAfterLogService artAfterLogService;

    /**
     * 查询售后操作记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:afterLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArtAfterLog artAfterLog)
    {
        startPage();
        List<ArtAfterLog> list = artAfterLogService.selectArtAfterLogList(artAfterLog);
        return getDataTable(list);
    }

    /**
     * 导出售后操作记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:afterLog:export')")
    @Log(title = "售后操作记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArtAfterLog artAfterLog)
    {
        List<ArtAfterLog> list = artAfterLogService.selectArtAfterLogList(artAfterLog);
        ExcelUtil<ArtAfterLog> util = new ExcelUtil<ArtAfterLog>(ArtAfterLog.class);
        util.exportExcel(response, list, "售后操作记录数据");
    }

    /**
     * 获取售后操作记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:afterLog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(artAfterLogService.selectArtAfterLogById(id));
    }

    /**
     * 新增售后操作记录
     */
    @PreAuthorize("@ss.hasPermi('system:afterLog:add')")
    @Log(title = "售后操作记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArtAfterLog artAfterLog)
    {
        return toAjax(artAfterLogService.insertArtAfterLog(artAfterLog));
    }

    /**
     * 修改售后操作记录
     */
    @PreAuthorize("@ss.hasPermi('system:afterLog:edit')")
    @Log(title = "售后操作记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArtAfterLog artAfterLog)
    {
        return toAjax(artAfterLogService.updateArtAfterLog(artAfterLog));
    }

    /**
     * 删除售后操作记录
     */
    @PreAuthorize("@ss.hasPermi('system:afterLog:remove')")
    @Log(title = "售后操作记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(artAfterLogService.deleteArtAfterLogByIds(ids));
    }
}
